package com.eastmelon.blog.controller;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import com.eastmelon.blog.entity.Channel;
import com.eastmelon.blog.entity.Link;
import com.eastmelon.blog.entity.Tags;
import com.eastmelon.blog.entity.User;
import com.eastmelon.blog.service.ChannelService;
import com.eastmelon.blog.service.LinkService;
import com.eastmelon.blog.service.TagsService;
import com.eastmelon.blog.service.UserService;

@Controller
@RequestMapping("/ajax")
public class AjaxViewController {
	@Resource
	private UserService userService;
	@Resource(name="channelService")
	private ChannelService channelService;
	@Resource(name="linkService")
	private LinkService linkService;
	@Resource(name="tagsService")
	private TagsService tagsService;
	
	@RequestMapping("/showUser")
	private ModelAndView showUser(int id){
		ModelAndView ma=new ModelAndView("ajaxView/userInforEdit");
		User user=userService.get(1);
		ma.addObject("user", user);
		return ma;
	}
	
	@RequestMapping("/showChannel")
	private ModelAndView showChannel(int id){
		ModelAndView ma=new ModelAndView("ajaxView/channelInforEdit");
		Channel channel=channelService.get(id);
		ma.addObject("channel", channel);
		return ma;
	}
	
	@RequestMapping("/showLink")
	private ModelAndView showLink(int id){
		ModelAndView ma=new ModelAndView("ajaxView/linkInforEdit");
		Link link=linkService.get(id);
		ma.addObject("link", link);
		return ma;
	}
	
	@RequestMapping("/showTags")
	private ModelAndView showTags(int id){
		ModelAndView ma=new ModelAndView("ajaxView/tagsInforEdit");
		Tags tags=tagsService.get(id);
		ma.addObject("tags", tags);
		return ma;
	}
	
}
